//package com.witmore.neutron.ai.cognitive.others.alitongyi;
//
//import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
//import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
//import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
//import com.alibaba.dashscope.common.MultiModalMessage;
//import com.alibaba.dashscope.common.Role;
//import com.witmore.neutron.ai.api.dto.MessageDTO;
//import com.witmore.neutron.ai.cognitive.others.AiModelAdapter;
//import com.witmore.neutron.ai.cognitive.others.ModelType;
//import com.witmore.neutron.ai.db.entity.ModelConfigDO;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//import org.springframework.util.ObjectUtils;
//
//import java.util.*;
//
//
///**
// * Description: TongyiModelAdapter
// * Author: 豆子高
// * Date: 2025/4/18 16:07
// */
//@Slf4j
//@Service
//public class TongyiModelAdapter implements AiModelAdapter {
//
//    @Override
//    public String generateResponse(ModelConfigDO modelConfigDO, MessageDTO messageBO) {
//        String promptFileByAgentType = messageBO.getSysPrompt();
//        MultiModalConversation conv = new MultiModalConversation();
//        // 系统提示词
//        MultiModalMessage systemMessage = MultiModalMessage.builder().role(Role.SYSTEM.getValue())
//                .content(List.of(
//                        Collections.singletonMap("text", promptFileByAgentType))).build();
//        // 用户提示词
//        List<Map<String, Object>> list = new ArrayList<>(List.of());
//        if (!ObjectUtils.isEmpty(messageBO.getUrl())) {
//            Map<String, Object> image = Collections.singletonMap("image", messageBO.getUrl());
//            list.add(image);
//        }
//        if (!ObjectUtils.isEmpty(messageBO.getMessage())) {
//            Map<String, Object> text = Collections.singletonMap("text", messageBO.getMessage());
//            list.add(text);
//        }
//        MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
//                .content(list).build();
//
//        MultiModalConversationParam param = MultiModalConversationParam.builder()
//                .apiKey(modelConfigDO.getModelApikey())
//                .model(modelConfigDO.getModelName())
//                .messages(Arrays.asList(systemMessage, userMessage))
//                .build();
//        MultiModalConversationResult result;
//        try {
//            result = conv.call(param);
//        } catch (Exception e) {
//            throw new RuntimeException(e);
//        }
//        Object object = result.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("text");
//        log.info("TongyiModelAdapter-->{}", object);
//        return object.toString();
//    }
//
//
//    @Override
//    public ModelType getModelName() {
//        return ModelType.TONG_YI;
//    }
//}
